<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JS函数</title>
</head>
<body>
<p>函数绑定</p>
<!--通过使用 bind() 方法，一个对象可以从另一个对象借用一个方法。-->
<p>此例将在 3 秒后显示人名：</p>
<p id="demo"></p>
<script>
  const person = {
    firstName:"Bill",
    lastName: "Gates",
    display: function() {
      let x = document.getElementById("demo");
      x.innerHTML = this.firstName + " " + this.lastName;
    }
  }
  let display = person.display.bind(person);
  setTimeout(display, 3000);
</script>
</body>
</html>